#!/usr/bin/env bash
# Copyright (c) Microsoft. All rights reserved.
# Note: Windows Bash doesn't support shebang extra params
set -e

# Note: use lowercase names for the Docker images
DOCKER_IMAGE="azureiotpcs/asa-manager-dotnet"

APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && cd .. && pwd )/"
source "$APP_HOME/scripts/.functions.sh"

run_container() {
    check_dependency_docker

    $APP_HOME/scripts/env-vars-check

    echo "Starting ASA manager ..."
    docker run -it -p 9024:9024 \
        -e PCS_TELEMETRY_WEBSERVICE_URL \
        -e PCS_CONFIG_WEBSERVICE_URL \
        -e PCS_IOTHUBMANAGER_WEBSERVICE_URL \
        -e PCS_ASA_DATA_AZUREBLOB_ACCOUNT \
        -e PCS_ASA_DATA_AZUREBLOB_KEY \
        -e PCS_ASA_DATA_AZUREBLOB_ENDPOINT_SUFFIX \
        -e PCS_EVENTHUB_CONNSTRING \
        -e PCS_EVENTHUB_NAME \
        -e PCS_AUTH_REQUIRED \
        -e PCS_CORS_WHITELIST \
        -e PCS_AUTH_ISSUER \
        -e PCS_AUTH_AUDIENCE \
        -e PCS_TWIN_READ_WRITE_ENABLED \
        -e PCS_TELEMETRY_DOCUMENTDB_CONNSTRING \
        -e PCS_TELEMETRY_STORAGE_TYPE \
        "$DOCKER_IMAGE:testing"
}

run_container